;/******************************************************************************
;//             INTEL CORPORATION PROPRIETARY INFORMATION
;//  This software is supplied under the terms of a license agreement or
;//  nondisclosure agreement with Intel Corporation and may not be copied
;//  or disclosed except in accordance with the terms of that agreement.
;//        Copyright (c) 2000 Intel Corporation. All Rights Reserved.
;//
;//  VSS: 
;//     $Workfile: $
;//     $Revision: $
;//     $Date: $
;//     $Archive: $
;//
;//  Description:
;//     INC file
;//
;//  History:
;//     Date        Author        Changes
;//     2000/6/20   Jerry Hu      Created
;//     2000/9/4    Jerry Hu      Add fast memory zero MACRO
;//
;******************************************************************************/

    MACRO
    _IPPMEMORYZEROGT8 $pData, $len, $temp1, $temp2
    EOR    $temp1,   $temp1,    $temp1
    TST    $pData,   #0x03
    BEQ    %F1
;
;   PASS 1
;
    STRB   $temp1,   [$pData],  #1    
    SUB    $len,     $len,      #1
    TST    $pData,   #0x03
    BEQ    %F1

    STRB   $temp1,   [$pData],  #1    
    SUB    $len,     $len,      #1
    TST    $pData,   #0x03
    STRNEB $temp1,   [$pData],  #1    
    SUBNE  $len,     $len,      #1
;
;   PASS 2
;
1
    SUBS   $temp2,   $len,      #4
    BLT    %F3
2        
    SUBS   $temp2,   $temp2,    #4
    STR    $temp1,   [$pData],  #4
    BGE    %B2
        
    ADDS   $len,     $temp2,    #4
    BLE    %F5
;
;   PASS 3
;
3
    SUBS   $len,     $len,      #1
    STRB   $temp1,   [$pData],  #1    
    BLE    %F5
    
    SUBS   $len,     $len,      #1
    STRB   $temp1,   [$pData],  #1    
    STRGTB $temp1,   [$pData],  #1    
5
    MEND


    MACRO
    _IPPMEMORYZEROGT32 $pData, $len, $temp1, $temp2, $temp3, $temp4

    MOV     $temp1,    #0
    MOV     $temp2,    #0
    MOV     $temp3,    #0

    ANDS    $temp4,   $pData,  #3                   ; if Aligned at DWORD boundary
    BNE     %F9                                     ; If not aligned process first bytes to meet alignment
    MOV     $temp4,   #0

    SUBS    $len,    $len,    #0x20
    BLT     %F2
1
    STMIA   $pData!,   {$temp1, $temp2, $temp3, $temp4}
    STMIA   $pData!,   {$temp1, $temp2, $temp3, $temp4}
    SUBS    $len,   $len,   #0x20                   ;  Store 32 Bytes perloop
    BGE     %B1

2
    ADD     $len,  $len,   #0x20                    ;   remaind length
    CMP     $len,    #0x10
    STMGEIA $pData!,   {$temp1, $temp2, $temp3, $temp4}
    SUBGE   $len,    $len,    #0x10
    
    CMP     $len,    #0x08 
    STMGEIA $pData!,   {$temp1, $temp2}             ; Store 12 bytes
    SUBGE   $len,    $len,    #0x08

    CMP     $len,    #0x04
    STRGE   $temp1,    [$pData], #0x04              ; Store 12 bytes
    SUBGE   $len,    $len,   #0x04

    CMP     $len,    #0x0
    BLE     %F5

    CMP     $len,    #2
    STRB    $temp1,    [$pData],  #1
    STRGEB  $temp1,    [$pData],  #1
    STRGTB  $temp1,    [$pData],  #1

9
    RSB     $temp4,    $temp4,   #4                 ; Computing head length for the alignment  
    CMP     $temp4,    #2
    STRB    $temp1,    [$pData],  #1
    STRGEB  $temp1,    [$pData],  #1
    STRGTB  $temp1,    [$pData],  #1
    SUB     $len,    $len,    $temp4                ; Adjust Data Length
    SUBS    $len,    $len,    #0x20       
    MOV     $temp4,   #0
    BGE     %B1
    B       %B2                                     ; Note: the input data length must be larger than or equal 32    
5
    MEND

    END